package org.edu.modules.jxzy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.edu.modules.jxzy.entity.JwJianzhu;
import org.edu.modules.jxzy.entity.JwJiaoshi;
import org.edu.modules.jxzy.mapper.JwJianzhuMapper;
import org.edu.modules.jxzy.service.IJwJianzhuService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Arrays;
import java.util.List;

/**
 * @Description: 学校建筑（楼）信息
 * @Author: jeecg-boot
 * @Date:   2021-04-15
 * @Version: V1.0
 */
@Service
public class JwJianzhuServiceImpl extends ServiceImpl<JwJianzhuMapper, JwJianzhu> implements IJwJianzhuService {

    @Override
    public boolean getByJzwh(String jzwh) {
        JwJianzhu jianzhu = baseMapper.selectOne(new QueryWrapper<JwJianzhu>().eq("JZWH", jzwh));
        if(jianzhu != null && jianzhu.getId()!=null){
            return true;
        }
        return false;
    }

    @Override
    public void updateStatusByIds(String ids, int status) {
        List<String> list = Arrays.asList(ids.split(","));
        for (String str:list) {
            baseMapper.updateById(new JwJianzhu().setId(Integer.parseInt(str)).setStatus(status));
        }
    }

    @Override
    public int queryCountByXqId(Integer xqId) {
        LambdaQueryWrapper<JwJianzhu> wrapper =  new LambdaQueryWrapper<>();
        wrapper.eq(JwJianzhu::getCampusId, xqId);
        wrapper.eq(JwJianzhu::getIsdelete, 0);
        return this.count(wrapper);
    }

}
